package com.photonpay.api.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 交易类型类型
 *
 * @author ：lo-
 * @date ：Created in 2023/11/23 11:56
 */
@Getter
@AllArgsConstructor
public enum TransactionTypeEnum {

    /**
     * 消费
     */
    AUTH("auth"),

    /**
     * 纠正授权
     */
    CORRECTIVE_AUTH("corrective_auth"),

    /**
     * 验证
     */
    VERIFICATION("verification"),

    /**
     * 撤销
     */
    VOID("void"),

    /**
     * 退款
     */
    REFUND("refund"),

    /**
     * 校正退款
     */
    CORRECTIVE_REFUND("corrective_refund"),

    /**
     * 充值
     */
    RECHARGE("recharge"),

    /**
     * 卡余额退还
     */
    RECHARGE_RETURN("recharge_return"),

    /**
     * 销卡退回
     */
    DISCARD_RECHARGE_RETURN("discard_recharge_return"),

    /**
     * 服务费
     */
    SERVICE_FEE("service_fee"),

    /**
     * 退款撤销
     */
    REFUND_REVERSAL("refund_reversal"),

    ;

    private final String code;

    public static TransactionTypeEnum getByCode(String code) {
        for (TransactionTypeEnum status : TransactionTypeEnum.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的交易类型 code: " + code);
    }
}
